<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/restrict/adminHome.xhtml">
	<f:metadata>
		<f:viewParam name="artista" value="#{artistaManagedBean.artista}" converter="artistaConversor" />
	</f:metadata>

	<ui:define name="titulo">
		<h:outputLabel value="MusicBay.com - #{msg.editar} #{msg.artista}" />
	</ui:define>

	<ui:define name="cont">
		<p:messages />
		<p:panel header="#{msg.editar} #{msg.artista}">
			<h:form id="form">
				<h:panelGrid columns="3" cellpadding="7">
					<h:outputLabel value="#{msg.artista}" for="nome" class="label" />
					<h:panelGroup>
						<p:inputText value="#{artistaManagedBean.artista.nome}" id="nome" label="#{msg.artista}"
							required="true" size="30" maxlength="30" requiredMessage="#{msg.nome} #{msg.naoInformado}">
							<f:validateLength minimum="2" maximum="30" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="nome" />

					<h:outputLabel value="#{msg.sobre} #{msg.artista}" for="sobre" class="label" />
					<h:panelGroup>
						<p:inputTextarea value="#{artistaManagedBean.artista.descricao}" cols="60" rows="10"
							id="sobre" autoResize="true" required="true" maxlength="500"
							requiredMessage="#{msg.descricao} #{msg.naoInformado}" />
					</h:panelGroup>
					<p:message for="sobre" />

					<h:outputLabel value="#{msg.generoMusical}" for="genero" class="label" />
					<h:panelGroup styleClass="checkBox">
						<p:selectManyCheckbox value="#{artistaManagedBean.artista.generos}" id="genero"
							required="true" requiredMessage="#{msg.invalido}: #{msg.generoMusical}"
							layout="pageDirection" converter="generoConversor">
							<f:selectItems value="#{generoManagedBean.generos}" var="genero" itemLabel="#{genero.genero}"
								itemValue="#{genero}" />
						</p:selectManyCheckbox>
					</h:panelGroup>
					<p:message for="genero" />


					<h:outputLabel value="#{msg.status}" for="status" class="label" />
					<h:panelGroup styleClass="checkBox">
						<p:selectOneRadio id="status" value="#{artistaManagedBean.artista.status}" required="true">
							<f:selectItem itemLabel="#{msg.ativo}" itemValue="1" />
							<f:selectItem itemLabel="#{msg.inativo}" itemValue="0" />
						</p:selectOneRadio>
					</h:panelGroup>
					<p:message for="status" />

					<h:outputLabel value="#{msg.imagem}" class="label" />
					<h:form enctype="multipart/form-data">
						<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}" mode="advanced"
							update="messages" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png|JGP)$/"
							styleClass="upload" auto="true" sizeLimit="30000">
						</p:fileUpload>
						<p:growl id="messages" showDetail="true" />
					</h:form>
					<h:outputLabel value="" />

					<p:commandButton id="showceditDialog" value="#{msg.concluir} #{msg.edicao}"
						oncomplete="editDialog.show()" />
					<p:commandButton id="cancel" value="#{msg.cancelar} #{msg.edicao}" action="listaArtista" ajax="false"/>

				</h:panelGrid>

				<p:confirmDialog id="editDialog" message="#{msg.concluir} #{msg.edicao}?"
					header="#{msg.concluir} #{msg.edicao}?" severity="alert" widgetVar="editDialog">

					<p:commandButton id="confirmar" value="#{msg.confirma}" ajax="false"
						actionListener="#{artistaManagedBean.actionUpdate}" oncomplete="editDialog.hide()">
						<f:attribute name="img" value="#{fileUploadController.by}" />
					</p:commandButton>
					<p:commandButton id="cancelar" value="#{msg.cancelar}" onclick="editDialog.hide()"
						type="button" />
				</p:confirmDialog>
			</h:form>

		</p:panel>
	</ui:define>
</ui:composition>
</html>